package com.idanchuang.component.redis;

import com.idanchuang.component.redis.annotation.RedisLimit;
import com.idanchuang.component.redis.util.RedisLimits;
import org.springframework.stereotype.Component;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * @author yjy
 * @date 2020/5/8 10:21
 **/
@Component
public class LimitService {

    private static AtomicInteger a = new AtomicInteger(0);

    @RedisLimit(value = 53, name = "source_name", appendKeys = {"#from"}, timeWindow = 1, factor = 0.01D, errMessage = "惨被限流")
    public void doSomething(String from) {
        System.out.println(from + " 通过: " + a.incrementAndGet());
    }
}
